
function init_papination(selector,current,total,func){
	$(selector).whjPaging({
        pageSizeOpt: [
                      {'value': 5, 'text': '5条/页', 'selected': true},
                      {'value': 10, 'text': '10条/页'},
                      {'value': 15, 'text': '15条/页'},
                      {'value': 20, 'text': '20条/页'}
                  ],
                  totalPage: 19,
                  showPageNum: 2,
                  firstPage: '首页',
                  previousPage: '上一页',
                  nextPage: '下一页',
                  lastPage: '尾页',
                  skip: '跳至',
                  confirm: '确认',
                  refresh: '刷新',
                  totalPageText: '共{}页',
                  isShowFL: false,
                  isShowPageSizeOpt: false,
                  isShowSkip: false,
                  isShowRefresh: false,
                  isShowTotalPage: false,
                  isResetPage: false,
                  callBack: function (currPage, pageSize) {
                      func(currPage,pageSize);
                  }
              });
	$(selector).whjPaging("setPage", current, total);
}


$(document).ready(function() {
	
	var videoObject = {
			container: '.video',
			variable: 'player',
			autoplay: false,
			live: false
	};
	var player ;
	
	
	
	var  searchData  ;
	
	setTimeout(() => {
		searchData= {
			 video_id: videoid,
			 start_date: new Date($("#start_time").val()),
			 end_date: new Date($("#end_time").val())
		 };
		getData(1);
	}, 300);
	
	
	
	 // 点击检索
	 $("#searchbtns").click(function(){
		 searchData={
				 video_id: videoid,
				 start_date: new Date($("#start_time").val()),
				 end_date: new Date($("#end_time").val())
		 }
		 getData(1);
	 })
	 
	 $(document).delegate(".list-detail p.second","click",function(){
		 var url = $(this).attr("url");
		 if(!validater.empty(url)){
			 player.newVideo({ autoplay:true, video:url }); 
			 $(".list-detail p.second").removeClass("active");
			 $(this).addClass("active");			 
		 }else{
			 tip("没有获取视频播放源，请检查");
		 }
	 })

	 function getData(n){
		 // 检索历史视频数据
		 domAjaxInit( {
			 url:'/page/video/record.json?pageSize=9&paged='+n,
			 data:searchData,
			 type:'page',
			 selector:'.list-container',
			 getContent:function(obj,i){
				 return '<div downUrl="'+ videoUrl + obj.name +'"  class="list-detail">\
				 <p class="first">'+(i+1)+'</p>\
				 <p class="second"  url="'+ videoUrl + obj.name +'" >' +timeStamp2String(obj.atime,'yyyy/MM/dd hh:mm:ss')  +'</p>\
				 <p class="third"><a href="'+ videoUrl + obj.name +'">下载</a></p>\
				 </div>';
			 },
			 success:function(data){
				var obj = data;
				$("#jppager").show();
				 init_papination("#jppager",obj.data.paged,obj.data.totalPage,function(n){
					 getData(n);
				 });
				 // 首个视频加载
				 if(obj.data.data.length >0){
//					 var url = obj.data.data[0].data.id_;
//					 myPlayer.src(url);  					
//					 myPlayer.load(url);  	
//					 myPlayer.play();
//					 paly_seq=0;
					 // 选中
//					 $(".list-detail .second").eq(paly_seq++).addClass("active");
					 videoObject["video"] = videoUrl+ obj.data.data[0].name ;
			
					 player=new ckplayer(videoObject);
					 
				 }
				
			 },
			 failure:function(){
				 $(".info-list-second").show();
				 $("#jppager").hide();
			 },
			 fail:function(){
				$("#jppager").hide();
				$(".info-list-second").show();
			 }
		 } );		 
	 }
	
})
